/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.report.controller;

import com.koron.common.StaffAttribute;
import com.koron.common.bean.StaffBean;
import com.koron.common.permission.SPIAccountAnno;
import com.koron.purpose.utils.BusinessCode;
import com.koron.report.bean.EventAnalysis;
import com.koron.report.service.api.EventAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.swan.bean.MessageBean;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@Api(tags = "eventAnalysis", description = "事故管理统计接口类")
@RestController
@RequestMapping("/eventAnalysis")
public class EventAnalysisController {
    @Autowired
    private EventAnalysisService analysisService;

    @ApiOperation("事件--统计集团/片区/水司下事件总体情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/queryCountEvent.htm", method = RequestMethod.GET)
    public MessageBean<?> queryCountEvent(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, Integer year) {
        if (null == user) {
            MessageBean<?> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryCountEvent(code, year);
    }

    @ApiOperation(" 事件--统计集团/部门/水司下的各个直接下属部门的情况列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/queryListEvent.htm", method = RequestMethod.GET)
    public MessageBean<?> queryListEvent(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, Integer year) {
        if (null == user) {
            MessageBean<?> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryListEvent(code, year);
    }

    @ApiOperation("事件--统计各个水司的事件总数列表,忽略片区级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/queryListEventGroupCorp.htm", method = RequestMethod.GET)
    public MessageBean<?> queryListEventGroupCorp(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, Integer year) {
        if (null == user) {
            MessageBean<?> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryListEventGroupCorp(code, year);
    }

    @ApiOperation("事故--统计集团/片区/水司下事故总体情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/queryCountAccident.htm", method = RequestMethod.GET)
    public MessageBean<?> queryCountAccident(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, Integer year) {
        if (null == user) {
            MessageBean<?> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryCountAccident(code, year);
    }

    @ApiOperation(" 事故--统计集团/部门/水司下的各个直接下属部门事故的情况列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/queryListAccident.htm", method = RequestMethod.GET)
    public MessageBean<?> queryListAccident(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, Integer year) {
        if (null == user) {
            MessageBean<?> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryListAccident(code, year);
    }

    @ApiOperation("事故--统计各个水司的事故列表,忽略片区级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/queryListAccidentGroupCorp.htm", method = RequestMethod.GET)
    public MessageBean<?> queryListAccidentGroupCorp(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, Integer year) {
        if (null == user) {
            MessageBean<?> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryListAccidentGroupCorp(code, year);
    }

    @ApiOperation("损工时--统计集团/片区/水司下损工时总体情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/queryCountWorkTime.htm", method = RequestMethod.GET)
    public MessageBean<EventAnalysis> queryCountWorkTime(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, String year) {
        if (null == user) {
            MessageBean<EventAnalysis> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryCountWorkTime(code, year);
    }

    @ApiOperation(" 损工时--统计集团/部门/水司下的各个直接下属部门损工时的情况列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/queryListWorkTime.htm", method = RequestMethod.GET)
    public MessageBean<List<EventAnalysis>> queryListWorkTime(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, String year) {
        if (null == user) {
            MessageBean<List<EventAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryListWorkTime(code, year);
    }

    @ApiOperation("损工时--统计各个水司的损工时列表,忽略片区级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/queryListWorkTimeGroupCorp.htm", method = RequestMethod.GET)
    public MessageBean<List<EventAnalysis>> queryListWorkTimeGroupCorp(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user, String code, String year) {
        if (null == user) {
            MessageBean<List<EventAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return analysisService.queryListWorkTimeGroupCorp(code, year);
    }
}
